package com.vng.zini.gifapp.utils;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;

import com.stay.gif.GifEncoder;
import com.vng.zini.gifapp.config.AppConstant;

public class CreateGIF {
	public static void create(Context context, ArrayList<Bitmap> lBitmap){
		int width = AppConstant.GIF_STANDARD_WIDTH;
		int height = AppConstant.GIF_STANDARD_HEIGHT;
		GifEncoder giflen = new GifEncoder();
		int state =	giflen.init("/sdcard/output.gif", width, height, 256, 50, 20);
		if (state != 0) {
			Log.e("TAG","Init gifflen error");
			return;
		}
		int [] pixels = new int[width * height];
		for(int i=0;i<lBitmap.size();i++){
			Bitmap bm = lBitmap.get(i);
			bm.getPixels(pixels, 0, width, 0, 0, width, height);
			giflen.addFrame(pixels);
		}
		giflen.close();
		
	}
	
}
